// 购物车
import request from '@/utils/request'
import qs from 'qs';
export default {
	// 获取搜索页面数据信息 https://m.you.163.com/xhr/search/init.json
	getSearchInfo(){
		return request.get(`/wy/xhr/search/init.json`)
	},
	// 搜索时实时获取搜索提示 https://m.you.163.com/xhr/search/searchAutoComplete.json POST
	// content-type: application/x-www-form-urlencoded; charset=UTF-8
	//data数据 keywordPrefix: 手
	getSearchTipsList(keywordPrefix){
		return request({
			url:`/wy/xhr/search/searchAutoComplete.json`,
			method: 'POST',
			headers: {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'},
			data:qs.stringify({keywordPrefix})
		})
	},
	// 点击搜索，获取搜索到的商品展示列表
	// https://m.you.163.com/xhr/search/search.json
	// https://m.you.163.com/xhr/search/search.json?__timestamp=1630401458565&needPopWindow=true&searchWordSource=1&stillSearch=false&_stat_search=userhand&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=%E6%89%8B%E6%9C%BA
	getSearchShowGoodsInfo({keyWords, categoryId = 0,min=-1,max=-1,descSorted,sortType=0,matchType=0}){
		return request({
			url:`/wy/xhr/search/search.json`,
			method: 'GET',
			params:{
				__timestamp: +new Date(),
				needPopWindow: true,
				searchWordSource: 5,
				stillSearch: false,
				// _stat_search: history,
				itemId: 0,
				size: 40,
				upperPrice: min,
				floorPrice: max,
				// floorPrice: 100
				// upperPrice: 1000
				matchType,
				categoryId: categoryId,
				descSorted,
				sortType,
				keyword:keyWords,
			}
		})
	}

}
